package com.xiaominfo.oss.service;

import com.xiaominfo.oss.domain.FileBinaryRequest;
import com.xiaominfo.oss.domain.FileBinaryResponse;
import com.xiaominfo.oss.module.model.OSSAppInfo;
import com.xiaominfo.oss.module.model.OSSDeveloper;
import com.xiaominfo.oss.module.model.OSSInformation;
import com.xiaominfo.oss.module.model.OSSMaterialInfo;
import com.xiaominfo.oss.sdk.client.NettyFileRequest;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * @Author lien
 * @Date 2019/12/24 17:03
 * @Description 文件存储操作service
 **/
public interface MaterialService {

    /***
     * 存储binary二进制文件
     * @param ossInformation oss描述对象
     * @param ossDeveloper
     * @param ossApp
     * @param projectDirectory
     * @param fileBinaryRequests
     * @return
     * @throws IOException
     */
    List<FileBinaryResponse> saveAndStore(OSSInformation ossInformation, OSSDeveloper ossDeveloper, OSSAppInfo ossApp, File projectDirectory, List<FileBinaryRequest> fileBinaryRequests) throws IOException;

    /**
     * 保存文件
     * @param ossInformation
     * @param ossDeveloper
     * @param ossApp
     * @param
     * @param file
     * @return
     * @throws IOException
     */
    FileBinaryResponse saveAndStore(OSSInformation ossInformation, OSSDeveloper ossDeveloper, OSSAppInfo ossApp,
                                    NettyFileRequest ef, File file) throws IOException;


    /***
     * 存储文件
     * @param projectDirectory
     * @param multipartFile
     * @return
     */
    List<FileBinaryResponse> saveAndStore(OSSInformation ossInformation, OSSDeveloper ossDeveloper, OSSAppInfo ossApp, File projectDirectory, MultipartFile[] multipartFile,String md5) throws IOException;

    List<FileBinaryResponse> saveAndStore(OSSInformation ossInformation, OSSDeveloper ossDeveloper, OSSAppInfo ossApp, File projectDirectory, MultipartFile[] multipartFile) throws IOException;

    /***
     * 系统后台用户保存文件
     * @param ossInformation
     * @param projectDirectory
     * @param multipartFile
     * @return
     * @throws IOException
     */
    List<FileBinaryResponse> saveAndStoreBySys(OSSInformation ossInformation, File projectDirectory, MultipartFile[] multipartFile) throws IOException;


    OSSMaterialInfo isfile(String md5);

}
